package com.ate.lib_core.http.product;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author Ate
 * @description:
 * @date :2020/12/10 11:16
 */
public class HttpRetrofitUploadImpl implements IRetrofitProduct {
    Retrofit mRetrofit;

    @Override
    public void create() {
        mRetrofit = new Retrofit.Builder()
                .baseUrl("")
                .client(new OkHttpClient.Builder()
                        .addInterceptor(new HttpLoggingInterceptor()
                                .setLevel(HttpLoggingInterceptor.Level.BODY)).build())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    @Override
    public Retrofit getRetrofit() {
        if (mRetrofit==null){
            create();
        }
        return mRetrofit;
    }
}
